package com.ljs.myspringboot.controller;

import com.ljs.myspringboot.entity.Customer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/*查看swagger的网站 设置了https转化 https://localhost/swagger-ui.html，没有的话https://localhost：8080/swagger-ui.html*/
@Controller
@RequestMapping("/swagger")
@Api("和用户相关的api")
public class SwaggerHandler {
    @RequestMapping("/swagger")
    @ApiOperation("用来测试的接口")
    public String swagger(Model model) {
        String s = "swagger";
        model.addAttribute("swagger", s);

        return "test";
    }

    @RequestMapping("/form")
    @ResponseBody
    @ApiOperation("转到form的接口")
    public ModelAndView form(Customer customer) {

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject(customer);
        modelAndView.setViewName("form");
        return modelAndView;
    }
}
